package encaps.utils.html;

import java.util.Iterator;

public class HTMLElementSequence extends HTMLElement {

    public HTMLElementSequence() {
        super(null);
    }

    @Override
    public String toString() {
        if (this.isEmpty(children)) {
            return "";
        }
        StringBuilder sb = new StringBuilder();
        Iterator iterator = children.iterator();
        while (iterator.hasNext()) {
            sb.append(iterator.next().toString());
            sb.append(" ");
        }

        return sb.toString();
    }

    public HTMLElementSequence addContentToHead(HTMLElement element) {
        children.add(0, element);
        return this;
    }
}
